﻿using System;
using NUnit.Framework;

namespace Duhking.Tests
{
    [TestFixture]
    public class FinderFactoryTests
    {
        public void AGenericMethod<T>(T item)
        {
        }

        public void ANonGenericMethod(object item)
        {
        }

        [Test]
        public void GetFinder_Returns_GenericMethodFinder_If_Method_Is_A_GenericMethodDefinition()
        {
            var method = GetType().GetMethod("AGenericMethod");
            var finder = FinderFactory.GetFinder(method);
            Assert.That(finder, Is.InstanceOf<GenericMethodFinder>());
        }

        [Test]
        public void GetFinder_Returns_GenericMethodFinder_If_Method_Is_GenericMethod()
        {
            var method = GetType().GetMethod("AGenericMethod").MakeGenericMethod(typeof(string));
            var finder = FinderFactory.GetFinder(method);
            Assert.That(finder, Is.InstanceOf<GenericMethodFinder>());
        }

        [Test]
        public void GetFinder_Returns_StandardMethodFinder_If_Method_Is_Not_Generic()
        {
            var method = GetType().GetMethod("ANonGenericMethod");
            var finder = FinderFactory.GetFinder(method);
            Assert.That(finder, Is.InstanceOf<StandardMethodFinder>());
        }
    }
}
